package com.jy.controller;

import com.jy.common.enums.ResponseWrapper;
import com.jy.common.model.dyamic.DeleteDynamicByNoteAidParam;
import com.jy.common.model.dyamic.ReleaseNoteParam;
import com.jy.common.model.dyamic.SaveDraftParam;
import com.jy.common.model.dyamic.SendComment;
import com.jy.common.tool.CommonTool;
import com.jy.service.DynamicService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 动态表（用户发的动态：包括笔记，视频，此刻） 前端控制器
 * </p>
 *
 * @author fzg
 * @since 2024-11-13
 */
@RestController
@RequestMapping("/dynamic")
public class DynamicController {
    private final DynamicService dynamicService;

    public DynamicController(DynamicService dynamicService) {
        this.dynamicService = dynamicService;
    }

    /**
     * 获取在线客服信息和用户动态信息
     * @param request request
     * @return ResponseWrapper
     */
    @GetMapping("/getOnlineConsultantInfoAndUserDynamic")
    public ResponseWrapper getOnlineConsultantInfoAndUserDynamic(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer size ) {
        return dynamicService.getOnlineConsultantInfoAndUserDynamic(CommonTool.getUserAidByToken(request),page,size);
    }

    /**
     * 获取屿粉-露营的动态列表
     * @return ResponseWrapper
     */
    @GetMapping("/getCampingDynamicList")
    public ResponseWrapper getCampingDynamicList(HttpServletRequest request, @RequestParam String travelMode){
        return dynamicService.getCampingDynamicList(CommonTool.getUserAidByToken(request), travelMode);
    }

    /**
     * 获取屿粉-美食的动态列表
     * @return ResponseWrapper
     */
    @GetMapping("/getFoodsList")
    public ResponseWrapper getFoodsList(HttpServletRequest request, @RequestParam String travelMode){
        return dynamicService.getFoodsList(CommonTool.getUserAidByToken(request), travelMode);
    }

    /**
     * 获取屿粉-民宿的动态列表
     * @return ResponseWrapper
     */
    @GetMapping("/getHomestayList")
    public ResponseWrapper getHomestayList(HttpServletRequest request, @RequestParam String travelMode){
        return dynamicService.getHomestayList(CommonTool.getUserAidByToken(request), travelMode);
    }

    /**
     * 获取屿粉-活动的动态列表
     * @return ResponseWrapper
     */
    @GetMapping("/getActivitiesList")
    public ResponseWrapper getActivitiesList(HttpServletRequest request, @RequestParam String travelMode){
        return dynamicService.getActivitiesList(CommonTool.getUserAidByToken(request),travelMode);
    }

    /**
     * 获取分享-附近的动态列表
     * @return ResponseWrapper
     */
    @GetMapping("/getNearList")
    public ResponseWrapper getNearList(HttpServletRequest request, @RequestParam String travelMode){
        return dynamicService.getNearList(CommonTool.getUserAidByToken(request), travelMode);
    }

    /**
     * 获取当前省份的城市列表
     * @return ResponseWrapper
     */
    @GetMapping("/getCityList")
    public ResponseWrapper getCityList(){
        return dynamicService.getCityList();
    }


    /**
     * 点击保存为草稿
     * @return ResponseWrapper
     */
    @PostMapping("/saveDraft")
    public ResponseWrapper saveDraft(HttpServletRequest request, @RequestBody SaveDraftParam param ){
        return dynamicService.saveDraft(CommonTool.getUserAidByToken(request), param);
    }


    /**
     * 发布笔记
     * @return ResponseWrapper
     */
    @PostMapping("/releaseNote")
    public ResponseWrapper releaseNote(HttpServletRequest request, @RequestBody ReleaseNoteParam param ){
        return dynamicService.releaseNote(CommonTool.getUserAidByToken(request), param);
    }


    /**
     * 获取话题列表和用户列表
     * @return ResponseWrapper
     */
    @GetMapping("/getTopicAndUsers")
    public ResponseWrapper getTopicAndUsers(HttpServletRequest request){
        return dynamicService.getTopicAndUsers(CommonTool.getUserAidByToken(request));
    }

    /**
     * 点击某一个笔记根据笔记aid获取笔记详细信息
     * @return ResponseWrapper
     */
    @GetMapping("/getNoteDetailInfos")
    public ResponseWrapper getNoteDetailInfos(HttpServletRequest request, @RequestParam Integer noteAid){
        return dynamicService.getNoteDetailInfos(CommonTool.getUserAidByToken(request),noteAid);
    }


    /**
     * 点赞或者取消点赞评论
     * @return ResponseWrapper
     */
    @PostMapping("/thumbsUpThisComment")
    public ResponseWrapper thumbsUpThisComment(HttpServletRequest request, @RequestParam Integer commentAid){
        return dynamicService.thumbsUpThisComment(CommonTool.getUserAidByToken(request),commentAid);
    }


    /**
     * 点赞或者取消点赞这个笔记
     * @return ResponseWrapper
     */
    @PostMapping("/thumbsUpNote")
    public ResponseWrapper thumbsUpNote(HttpServletRequest request, @RequestParam Integer noteAid){
        return dynamicService.thumbsUpNote(CommonTool.getUserAidByToken(request),noteAid);
    }



    /**
     * 收藏或者取消收藏这个笔记
     * @return ResponseWrapper
     */
    @PostMapping("/collectNote")
    public ResponseWrapper collectNote(HttpServletRequest request, @RequestParam Integer noteAid){
        return dynamicService.collectNote(CommonTool.getUserAidByToken(request),noteAid);
    }


    /**
     * 点击关注或者取消关注作者
     * @return ResponseWrapper
     */
    @PostMapping("/guanzhuAuthor")
    public ResponseWrapper guanzhuAuthor(HttpServletRequest request, @RequestParam Integer authorAid){
        return dynamicService.guanzhuAuthor(CommonTool.getUserAidByToken(request),authorAid);
    }


    /**
     * 发送评论
     * @return ResponseWrapper
     */
    @PostMapping("/sendCommentContent")
    public ResponseWrapper sendCommentContent(HttpServletRequest request, @RequestBody @Validated SendComment param){
        return dynamicService.sendCommentContent(CommonTool.getUserAidByToken(request),param);
    }


    /**
     * 删除笔记
     * @return ResponseWrapper
     */
    @PostMapping("/deleteDynamic")
    public ResponseWrapper deleteDynamic(HttpServletRequest request, @RequestBody @Validated DeleteDynamicByNoteAidParam param){
        return dynamicService.deleteDynamic(CommonTool.getUserAidByToken(request),param);
    }

}
